import { request } from "@/plugins/request";

export const getArticles = params => request({
  method: "GET",
  url: "/api/articles",
  params
})

export const getYourFeedArticles = params => request({
  method: "GET",
  url: "/api/articles/feed",
  params,
  headers: {
    Authorization: `Token `
  }
})

export const addFavorite = async slug => request({
  method: "POST",
  url: `/api/articles/${slug}/favorite`,
})

export const deleteFavorite = async slug => request({
  method: "DELETE",
  url: `/api/articles/${slug}/favorite`,
})

export const getArticle = async slug => request({
  method: "GET",
  url: `/api/articles/${slug}`,
})

export const getComments = async slug => request({
  method: "GET",
  url: `/api/articles/${slug}/comments`,
})